package cn.rokhdelar.ams.business.biz.project.controller;

import cn.rokhdelar.ams.base.BaseController;
import cn.rokhdelar.ams.base.CustomResponse;
import cn.rokhdelar.ams.business.biz.project.domain.po.BizWxReport;
import cn.rokhdelar.ams.business.biz.project.domain.vo.BizWxReportAddVo;
import cn.rokhdelar.ams.business.biz.project.domain.vo.ManagerReportPageVo;
import cn.rokhdelar.ams.business.biz.project.domain.vo.WxReportPageVo;
import cn.rokhdelar.ams.business.biz.project.service.WxReportService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author 范书铭
 * @date 2025年07月14日 14:21
 */
@Tag(name = "微信投诉反馈", description = "微信投诉反馈")
@Controller
@RequestMapping("/wxReport")
@RequiredArgsConstructor
public class WxReportController extends BaseController {
    private final WxReportService bizWxReportService;
    @Operation(summary = "微信用户提交投诉反馈", description = "提交投诉反馈")
    @PostMapping("wxNoAuth/submitReport")
    public CustomResponse<String> wxUserSubmitReport(@RequestBody BizWxReportAddVo wxReportAddVo) {
        bizWxReportService.wxUserSubmitReport(wxReportAddVo);
        return CustomResponse.success("ok");
    }

    /**
     * 删除投诉反
     */
    @Operation(summary = "微信用户删除投诉反馈", description = "删除投诉反馈")
    @PostMapping("wxNoAuth/deleteReport/{wxOpenId}/{reportId}")
    public CustomResponse<String> deleteReport(@PathVariable String wxOpenId, @PathVariable String reportId) {
        //TODO 进入执法后不允许删除
        bizWxReportService.deleteReport(wxOpenId,reportId);
        return CustomResponse.success("ok");
    }
    /**
     * 获取投诉反馈列表
     */
    @Operation(summary = "获取投诉反馈列表", description = "获取投诉反馈列表")
    @PostMapping("wxNoAuth/getReportList")
    public CustomResponse<IPage<BizWxReport>> wxUserGetReportList(@RequestBody WxReportPageVo pageQuery) {
        return CustomResponse.success(bizWxReportService.getWxUserReportList(pageQuery));
    }
    /**
     *  微信用户获取投诉反馈详情
     *
     */
    @Operation(summary = "微信用户获取投诉反馈详情", description = "微信用户获取投诉反馈详情")
    @PostMapping("wxNoAuth/getReportDetail/{reportId}")
    public CustomResponse<BizWxReport> wxUserGetReportDetail(@PathVariable String reportId) {
        return CustomResponse.success(bizWxReportService.getById(reportId));
    }

    /**
     * 后台管理获取投诉反馈列表
     */
    @Operation(summary = "后台管理获取投诉反馈列表", description = "后台管理获取投诉反馈列表")
    @PostMapping("/getReportList")
    public CustomResponse<IPage<BizWxReport>> getReportList(@RequestBody ManagerReportPageVo pageQuery) {
        return CustomResponse.success(bizWxReportService.getReportListByStatus(pageQuery));
    }

    /**
     * 修改投诉状态
     */
    @Operation(summary = "修改投诉状态", description = "修改投诉状态:0未处理 1仅回复 2已转执法 3无效投诉 4.骚扰投诉")
    @PostMapping("/updateReportStatus/{reportId}")
    public CustomResponse<String> updateReportStatus(@PathVariable String reportId, @RequestParam String status) {
        bizWxReportService.updateReportStatus(reportId,status);
        return CustomResponse.success("ok");
    }
    /**
     * 投诉转执法
     */
    @Operation(summary = "投诉转执法", description = "修改投诉状态:0未处理 1仅回复 2已转执法 3无效投诉 4.骚扰投诉")
    @PostMapping("/changeToLawEnforcement/{reportId}")
    public CustomResponse<String> changeToLawEnforcement(@PathVariable String reportId) {
        bizWxReportService.changeToLawEnforcement(reportId);
        return CustomResponse.success("ok");
    }

}
